import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ShopVO, ShopForm, ShopQuery } from '@/api/system/shop/types';

/**
 * 查询门店列表
 * @param query
 * @returns {*}
 */

export const listShop = (query?: ShopQuery): AxiosPromise<ShopVO[]> => {
  return request({
    url: '/system/shop/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询门店详细
 * @param id
 */
export const getShop = (id: string | number): AxiosPromise<ShopVO> => {
  return request({
    url: '/system/shop/' + id,
    method: 'get'
  });
};

/**
 * 新增门店
 * @param data
 */
export const addShop = (data: ShopForm) => {
  return request({
    url: '/system/shop',
    method: 'post',
    data: data
  });
};

/**
 * 修改门店
 * @param data
 */
export const updateShop = (data: ShopForm) => {
  return request({
    url: '/system/shop',
    method: 'put',
    data: data
  });
};

/**
 * 删除门店
 * @param id
 */
export const delShop = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/shop/' + id,
    method: 'delete'
  });
};
